package com.updateeproject;

/**
 * Hello world!
 */

import com.updateeproject.dao.UserDOMapper;
import com.updateeproject.dataobject.UserDO;
import org.mybatis.spring.annotation.MapperScan;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.EnableAutoConfiguration;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * 把这个App的类把它变成一个springboot的一个bean 并且可以启动自动化的一个配置5'00
 * @EnableAutoConfiguration
 */
//让springboot去扫描mybatis的一些配置文件
//@EnableAutoConfiguration
@SpringBootApplication(scanBasePackages = {"com.updateeproject"})
@RestController
//dao存放的位置设置在这个注解下
@MapperScan("com.updateeproject.dao")
public class App {

    @Resource
    private UserDOMapper userDOMapper;  //接口名称作为成员变量名称

    @RequestMapping("/")
    public String home() {
        UserDO userDO = userDOMapper.selectByPrimaryKey(1);
        if (userDO == null) {
            return "用户对象不存在！";
        } else {
            return "这TM是" + userDO.getName() + "laker";
        }


//        if (userDO==null){
//            return "没这玩意儿！";
//        }else {
//            System.out.println(userDO.getName() + userDO.getTelphone());
//        }
//        return "当用户访问根路径时，输出这段话到控制台上";
    }

    public static void main(String[] args) {
        System.out.println("Hello World!");
        SpringApplication.run(App.class, args);
    }
}
